<template>
	<view>
		<uni-list-item title="姓名">
			<view class="flex align-center" slot="right">
				<input class="uni-input text-right"  v-model="animalName" />
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		
		<uni-list-item title="种类" @click="changeSpecies">
			<view class="flex align-center" slot="right">
				<text>{{speciesInfo}}</text>
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		<uni-list-item title="免疫状况" @click="changeImmune">
			<view class="flex align-center" slot="right">
				<text>{{immuneInfo}}</text>
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		<uni-list-item title="驱虫状况" @click="changeParasite">
			<view class="flex align-center" slot="right">
				<text>{{parasiteInfo}}</text>
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		<uni-list-item title="绝育状况" @click="changeSterilized">
			<view class="flex align-center" slot="right">
				<text>{{sterilizedInfo}}</text>
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		<uni-list-item title="简介">
			<view class="flex align-center" slot="right">
				<input class="uni-input text-right"  v-model="animalBrief" />
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		<view style="margin-left: 30rpx; margin-bottom: 30rpx;">
			<text style="font-size: 30rpx;">介绍</text>
		</view>
		
		<textarea v-model="animalIntroduction" placeholder="添加介绍" style="height: 200rpx;" class="uni-textarea px-2"/>
		
		<view class="flex align-center justify-center py-2 px-3">
			<button class="bg-main text-white" style="border-radius: 50rpx;border: 0; width: 700rpx;" type="primary" @click="submit">申请新增</button>
		</view>
		
		
	</view>
</template>

<script>
	const sexArray = ['男', '女']
	const speciesArray = ['狗','猫']
	const immuneArray = ['未免疫', '已免疫']
	const parasiteArray = ['未驱虫', '已驱虫']
	const sterilizedArray = ['未绝育', '已绝育']
	const petArray = ['毛孩自由派', '云宠爱', '毛孩家长']
	import uniListItem from '@/components/uni-ui/uni-list-item/uni-list-item.vue';
	import mpvueCityPicker from '@/components/uni-ui/mpvue-citypicker/mpvueCityPicker.vue';
	
	import { mapState } from 'vuex'
	import Vue from 'vue'
	
	
	export default {
		components: {
			uniListItem,
			mpvueCityPicker
		},
		data() {
			return {
				id: "",
				animalName: "",
				species: "",
				speciesInfo: "",
				stationId: "",
				stationName: "",
				sterilized: "",
				sterilizedInfo: "",
				immune: "",
				immuneInfo: "",
				parasite: "",
				parasiteInfo: "",
				animalBrief: "",
				animalIntroduction: "",
				claimPrice: 10,
				claimStatus: 0,
				imgList: ""
			}
		},
		onLoad(){
			this.$H.get('/rescue_station/byIdSearchStation/'+this.$store.state.user.id).then(res=>{
				this.stationId = this.$store.state.user.id
				this.stationName = res.stationName
			}).catch(err=>{
			})
		},
		methods: {
			
			changeImmune(){
				uni.showActionSheet({
				    itemList: immuneArray,
				    success:(res)=>{
				        this.immune = res.tapIndex
						this.immuneInfo = immuneArray[this.immune]
				    }
				});
			},
			changeSpecies(){
				uni.showActionSheet({
				    itemList: speciesArray,
				    success:(res)=>{
				        this.species = res.tapIndex
						this.speciesInfo = speciesArray[this.species]
				    }
				});
			},
			changeParasite(){
				uni.showActionSheet({
				    itemList: parasiteArray,
				    success:(res)=>{
				        this.parasite = res.tapIndex
						this.parasiteInfo = parasiteArray[this.parasite]
				    }
				});
			},
			changeSterilized(){
				uni.showActionSheet({
				    itemList: sterilizedArray,
				    success:(res)=>{
				        this.sterilized = res.tapIndex
						this.sterilizedInfo = sterilizedArray[this.sterilized]
				    }
				});
			},
			// 提交
			submit(){
				let obj = {
					animalName: this.animalName,
					species: this.species,
					stationId: this.stationId,
					stationName: this.stationName,
					sterilized: this.sterilized,
					immune: this.immune,
					parasite: this.parasite,
					animalBrief: this.animalBrief,
					animalIntroduction: this.animalIntroduction,
					claimPrice: this.claimPrice,
					ownerId: this.$store.state.user.id,
					claimStatus: this.claimStatus,
					imgList: this.imgList
				}
				console.log(obj);
				this.$H.post('/rescue_station/addAnimal/'+obj.stationId,obj).then(res=>{
					console.log(res);
					uni.navigateBack({
						delta: 2
					});
					uni.showToast({
						title: '新增动物申请已提交',
						icon: 'none'
					});
				})
			}
			
			
		}
	}
</script>

<style>

</style>
